{echo:JS::import('dialog?skin=brief');}
{echo:JS::import('dialogtools');}
{echo:JS::import('form');}
<form name="zform" action="" method="post">
<div class="tools_bar clearfix">
    <!-- <a class="icon-checkbox-checked icon-checkbox-unchecked" href="javascript:;" onclick="tools_select('id[]',this)" title="全选" data="true"> 全选 </a> -->
    <!-- <a  class="icon-remove-2" href="javascript:;" onclick="tools_submit({action:'{url:/customer/customer_del}',msg:'删除后无法恢复，你真的删除吗？'})" title="删除"> 删除</a> -->
    <!-- 
    <a href='{url:/customer/customer_edit}' class="icon-plus" > 添加</a>
    -->
    <a class="icon-delicious" href="{url:/customer/customer_list}"> 全部用户</a>
    <span class="fr"><a href='javascript:;' id="condition" class="icon-search" style="" > 筛选条件</a><input id="condition_input" type="hidden" name="condition" value="{$condition}"></span>
</div>
<table class="default" >
    <tr>
    	
        <th style="width:70px">操作</th>
        <th>账号</th>
        <th>姓名</th>
        <th>编码</th>
        <th>推荐人</th>
        <th>直推人数</th>
        <th>消费积分</th>
        <th>账户余额</th>
        <th>推广额度(总额)</th>
        <th>推广额度(已用)</th>
        <th>推广额度(剩余)</th>
        <th>云积分</th>
        <th>通用积分</th>
        <th>消费券</th>
        <th>团队业绩</th>
        <th style="width:120px">注册时间</th>
        <th>状态</th>
        <th>会员类型</th>

    </tr>
    {query:name=customer as c,user as u where=c.user_id eq u.id and $where id=$obj page=1 pagesize=13 order=u.id desc }
        <tr>
        
        <td style="width:70px" class="btn_min"><div class="operat hidden"><a  class="icon-cog action" href="javascript:;"> 处理</a><div class="menu_select"><ul>
                <li><a class="icon-coin" href="javascript:balance_op({$item['user_id']},2);"> 充值</a></li>
                <li><a class="icon-credit" href="javascript:balance_op({$item['user_id']},4);"> 扣款</a></li>
                
                {if:$item['is_seller']==0}
                <li><a class="icon-pencil" href="javascript:confirm_action('{url:/customer/set_seller/id/$item[id]}','确认执行此操作吗？')">设为商家</a></li>
                {/if}
                
                <li><a class="icon-pencil" href="javascript:confirm_action('{url:/customer/set_u_lx/id/$item[id]/lx/1}','确认执行此操作吗？')"> 开通服务中心</a></li>
                {if:$item['u_lx']==1}
                <li><a class="icon-pencil" href="javascript:confirm_action('{url:/customer/unset_u_lx/id/$item[id]}','确认执行此操作吗？')"> 取消服务中心</a></li>
                {/if}
                <li><a class="icon-pencil" href="javascript:confirm_action('{url:/customer/set_u_lx/id/$item[id]/lx/2}','确认执行此操作吗？')"> 开通分公司</a></li>
                {if:$item['u_lx']==2}
                <li><a class="icon-pencil" href="javascript:confirm_action('{url:/customer/unset_u_lx/id/$item[id]}','确认执行此操作吗？')"> 取消分公司</a></li>
                {/if}
                <li><a class="icon-pencil red" href="javascript:confirm_action('{url:/customer/customer_nojj/id/$item[id]}','确认执行此操作吗？')"> {echo:$item['nojj']==0?"冻结":"解冻";}</a></li>
                {if:$item['status']>0}
                <li><a class="icon-pencil red" href="javascript:confirm_action('{url:/customer/customer_clock/id/$item[id]}','确认执行此操作吗？')"> {echo:$item['status']==1?"锁定":"解锁";}</a></li>
                {/if}
                {if:$item['status']>0}
                <!-- 
                <li><a class="icon-pencil red" href="javascript:confirm_action('{url:/customer/tjr_ok/id/$item[id]}','确认此操作吗？')"> {echo:$item['tjr_index']==0?"注册选择":"取消注册选择";}</a></li>
                -->
                {/if}
                <li><a class="icon-pencil" href="{url:/customer/customer_edit/id/$item[id]}"> 编辑</a></li>
                <!-- <li><a class="icon-remove-2" href="javascript:confirm_action('{url:/customer/customer_del/id/$item[id]}')"> 删除</a></li> -->
            </ul></div></div> </td>
        <td>{$item['name']}
        	{if:$item['is_seller']==1}
        		<b style="color:red;">商</b>
        	{/if}
        </td>
        <td>{$item['real_name']}
        </td>
        <td>{$item['number']}</td>
        <td>{echo:Common::getUid($item['tjr_id'])['name']}</td>
        <td>{$item['u_tjrs']}</td>
        <td>
        	冻结:{$item['dj_xfjf']}<br>
        	可用:{$item['ok_xfjf']}<br>
        	已释放:{$item['sf_xfjf']}
        </td>
        <td>{$item['balance']}</td>
        <td>
        	{$item['extend_je']}
        </td>
        <td>
        	{$item['extend_used_je']}
        </td>
        <td>
        	{$item['extend_last_je']}
        </td>
        <td>{$item['cloud_point']}</td>
        <td>{$item['currency_point']}</td>
        <td>{$item['voucher']}</td>
        <td>{$item['tuan_yj']}</td>
        <td>{$item['reg_time']}</td>
        <td>
        	{if:$item['is_hg']==1}
        		合格&nbsp;
        	{/if}
        	{echo:$item['status']==0?"未激活":($item['status']==1?"正常":"锁定");}&nbsp;&nbsp;<span class='red'>{echo:$item['nojj']==1?"冻结":"";}</span></td>
        <!-- <td style="width:80px">{$grade_name[$item['group_id']]|'默认会员'}</td> -->
        <td>
        	{echo:Common::getShenfenname($item['u_lx'])}
        	<!-- 
        	{echo:Common::getShenfenName($item['u_lx'])}&nbsp;&nbsp;<span class='red'>{echo:Common::getAgentName($item['dl_lx'])}</span>&nbsp;&nbsp;{echo:$item['lgd_ok']>0?Common::getShenfenName($item['lgd_ok']):"";}&nbsp;&nbsp;{echo:$item['gd_ok']>0?Common::getShenfenName($item['gd_ok']):"";}
        	-->
        </td>
        </tr>
    {/query}
</table>
</form>
<div class="page_nav">
{echo:$obj->pageBar()}
</div>


<div id="balance_box" style="display: none;width:600px;padding: 5px;" class="box">
    <h2 class="page_title tc" style="border:none" id="balance-title">充值</h2>
    <div class="form2">
        <form  id="export_form" action="{url:/customer/balance_act}" method="post" callback="create_voucher">
          <input type="hidden" id="user_id" name="user_id" value="">
          <input type="hidden" id="type" name="type" value="">
          <dl class="lineD">
          	<dt>钱包类型：</dt>
          	<dd>
          		<input type="radio" name="account_type" value="1"/>账户余额&nbsp;
          		<input type="radio" name="account_type" value="2"/>消费积分(冻结)&nbsp;
          		<input type="radio" name="account_type" value="3"/>消费积分(可用)&nbsp;
          		<input type="radio" name="account_type" value="4"/>云积分&nbsp;
          		<input type="radio" name="account_type" value="6"/>通用积分
          	</dd>
          	<dt>&nbsp;&nbsp;</dt>
          	<dd>
          		<input type="radio" name="account_type" value="7"/>消费券&nbsp;
          		<input type="radio" name="account_type" value="5"/>推广额度(总额)&nbsp;
          		<input type="radio" name="account_type" value="8"/>推广额度(剩余)&nbsp;
          		<input type="radio" name="account_type" value="9"/>推广额度(已用)
          		
          		
          	</dd>
          </dl>
          
          
          <dl class="lineD">
          <dt>金额：</dt>
          <dd><input id="amount" pattern="float" min="0.01"   name="amount" alt="最少0.01"> <label id="lb_msg"></label></dd>
          </dl>
        <div class="tc mt10"><button class="button" id="balance-btn">充值</button></div>
        </form>
    </div>
</div>

<script type="text/javascript">

//将输入的数字金额转换成对应的中文大写金额
//idNumber输入的数字金额，idCHN输出的中文大写金额
function TransformNumberIntoCHN(number) 
{
	 if (!/^(0|[1-9]\d*)(\.\d{1,2})?$/.test(number)) {

	     return false;
	 }
	 var unit = "仟佰拾亿仟佰拾万仟佰拾元角分", str = "";
	 number += "00";
	 var point = number.indexOf('.');
	 if (point >= 0) {
	     number = number.substring(0, point) + number.substr(point + 1, 2);
	 }
	 unit = unit.substr(unit.length - number.length);
	 for (var i = 0; i < number.length; i++) {
	     str += '零壹贰叁肆伍陆柒捌玖'.charAt(number.charAt(i)) + unit.charAt(i);
	 }
	 //document.getElementById(idCHN).value = str.replace(/零(仟|佰|拾|角)/g, "零").replace(/(零)+/g, "零").replace(/零(万|亿|元)/g, "$1").replace(/(亿)万|壹(拾)/g, "$1$2").replace(/^元零?|零分/g, "").replace(/元$/g, "元整");
	 return str.replace(/零(仟|佰|拾|角)/g, "零").replace(/(零)+/g, "零").replace(/零(万|亿|元)/g, "$1").replace(/(亿)万|(拾)/g, "$1$2").replace(/^元零?|零分/g, "").replace(/元$/g, "元整");
}

$(function(){
	$("#amount").blur(function(){
		var amount = $("#amount").val();
		if(isNaN(amount) || amount == '')
		{
			$("#lb_msg").text('');
			return;
		}
		var dxje = TransformNumberIntoCHN(amount);
		$("#lb_msg").text(dxje);
	});
});



    function balance_op(user_id,type){
        $("#user_id").val(user_id);
        $("#type").val(type);
        var title = "充值";
        if(type==4) title = "扣款";
        $("#balance-title").text(title);
        $("#balance-btn").text(title);
        $("#amount").val('');
        art.dialog({id:'balance_op',lock:true,opacity:0.1,title:title,width:600,height:200,padding:"15px",content:document.getElementById("balance_box")});
    }
    function create_voucher(e){
      if(e == null){
    	  $("#balance-btn").attr("disabled", true);
        var fields = $("#export_form").serializeArray();
        $.get("{url:/customer/balance_op}",fields,function(data){
          if(data['status']=='success'){
            art.dialog({id:'balance_op'}).close();
            art.dialog.tips("<p class='"+data['status']+"'>"+data['msg']+"</p>",2);
            setTimeout("tools_reload()",2000);
          }else{
            art.dialog.tips("<p class='"+data['status']+"'>"+data['msg']+"</p>");
          }
          $("#balance-btn").attr("disabled", false);
        },'json');
      }
      return false;
    }
</script>

<script type="text/javascript">
    var form =  new Form();
    $("#condition").on("click",function(){
    //$("body").Condition({input:"#condition_input",okVal:'高级搜索',callback:function(data){tools_submit({action:'{url:/customer/customer_list}',method:'get'});},data:{'name':{name:'账号'},real_name:{name:'姓名'},status:{name:'是否锁定',values:{1:'正常',2:'锁定'}},nojj:{name:'是否冻结',values:{0:'正常',1:'冻结'}},u_lx:{name:'身份',values:{0:'普通',1:'创客',2:'商家'}},mobile:{name:'手机号码'},reg_time:{name:'注册时间'}
    $("body").Condition({input:"#condition_input",okVal:'高级搜索',callback:function(data){tools_submit({action:'{url:/customer/customer_list}',method:'get'});},data:{'name':{name:'账号'},real_name:{name:'姓名'},number:{name:'编码'},status:{name:'是否锁定',values:{1:'正常',2:'锁定'}},nojj:{name:'是否冻结',values:{0:'正常',1:'冻结'}},u_lx:{name:'身份',values:{0:'普通',1:'服务中心',2:'分公司'}},dj_xfjf:{name:'消费积分 冻结'},ok_xfjf:{name:'消费积分 可用'},balance:{name:'账户余额'},extend_je:{name:'推广额度 总额'},extend_used_je:{name:'推广额度 剩余'},cloud_point:{name:'云积分'},currency_point:{name:'通用积分'},tuan_yj:{name:'团队业绩'},voucher:{name:'消费券'},reg_time:{name:'注册时间'}
    }});
    });
</script>
